home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Demo's / Igor Demo Pro / 1 PutContentsIn Igor Pro Folder / WaveMetrics Procedures / Utilities / String Utilities / String Substitution < prev    next >
Text File  |  1994-02-18  |  468b  |  21 lines

  1. | <String Substitution>
  2. |
  3. | returns theStr with all instances of srcPat in theStr replaced with destPat
  4. | note: Search is case sensitive
  5.  
  6. Function/S StrSubstitute(srcPat,theStr,destPat)
  7.     String srcPat,theStr,destPat
  8.     
  9.     Variable sstart=0,sstop,srcLen= strlen(srcPat), destLen= strlen(destPat)
  10.     do
  11.         sstop= strsearch(theStr, srcPat, sstart)
  12.         if( sstop < 0 )
  13.             break
  14.         endif
  15.         theStr[sstop,sstop+srcLen-1]= destPat
  16.         sstart= sstop+destLen
  17.     while(1)
  18.     return theStr
  19. End
  20.  
  21.